﻿@{
    ViewBag.Title = "Customer Type";
    Layout = Settings.DefaultLayout();
    IQueryable<LeadCRM.Entities.CustomerTypeMaster> customerTypeList = ViewBag.CustomerType;
}
@section scripts
{
    @Scripts.Render("~/Scripts/Models/CustomerType.js")
    <script>
        $(document).ready(function () {
            $("#CusType").validate();
        });
    </script>
}
@if (ViewBag.Msg != null)
{ 
    @ViewBag.Msg
}
<br />
@if (ViewBag.Error != null)
{ 
    <div class="alert alert-error">
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        <h4>Error!</h4>
        @ViewBag.Error
    </div>    
}

@if (ViewBag.MsgSuccess != null)
{ 
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        <h4></h4>
        @ViewBag.MsgSuccess

    </div>    
}


<h2>Customer Type</h2>

<button class="btn" onclick="AddCustomerType('','0','New Customer Type')">Add New Customer Type</button>
<br />
<br />
<table class="table table-bordered">
    <thead>
        <tr>
            <th>Customer Type
            </th>
            <th>Edit
            </th>
            <th>Delete
            </th>
        </tr>
        @foreach (var item in customerTypeList)
        {
            <tr>
                <td>
                    @item.CustomerTypeName
                </td>
                <td>
                    <a href="#" onclick="AddCustomerType('@item.CustomerTypeName' , '@item.ID.ToString()','Edit Customer Type')" class="btn btn-primary">Edit</a>
                </td>
                <td>
                    <a href="#" class="btn btn-danger" onclick="DeleteCustomerType('@item.ID.ToString()')">Delete</a>
                </td>
            </tr>
        }
    </thead>
</table>

<!-- Modal -->
@using (Html.BeginForm("CustomerType", "Masters", FormMethod.Post, new { id = "CusType" }))
{
    <div id="CustomerTypeModel" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
        aria-hidden="true">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="ModelLeadHeader">Customer Type</h3>
        </div>

        <input type="hidden" value="Add" name="Command" id="Command">
        <div class="modal-body center">
            <div class="row">
                <div class="span2">
                    Customer Type:
                </div>
                <div class="span2">
                    @Html.TextBox("CustomerTypeName", "", new { @class = "required" })
                    @Html.Hidden("CustomerTypeID")
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
            <button class="btn btn-primary" type="submit" id="btnSave">Save changes</button>
        </div>
    </div>
}
@using (Html.BeginForm("CustomerType", "Masters", FormMethod.Post))
{
    <div id="DeleteCustomerTypeModel" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
        aria-hidden="true">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="ModelLeadHeader">Delete Customer Type</h3>
        </div>

        <input type="hidden" value="Delete" name="Command" id="Command">
        <div class="modal-body center">
            <div class="row">
                <div class="span5">
                    Are you sure you want to deleted this?
                    @Html.Hidden("CustomerTypeID")
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
            <button class="btn btn-primary" type="submit" id="btnDelete">Delete</button>
        </div>
    </div>
}
